#include <retro.h>
#include "retro.creator.h"

using namespace Retro::Creator;

BOOL  FrameState::load(PCTSTR iFilename)
{
  HANDLE wFile = CreateFile(
    iFilename, GENERIC_READ, 0, NULL,
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

  if (wFile == INVALID_HANDLE_VALUE)
    return FALSE;

  BOOL wResult = IO::ReadBuffer(wFile, &header, sizeof(header));

  CloseHandle(wFile);

  return TRUE;
}

BOOL  FrameState::save(PCTSTR iFilename)
{
  HANDLE wFile = CreateFile(
    iFilename, GENERIC_WRITE, 0, NULL,
    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

  if (wFile == INVALID_HANDLE_VALUE)
    return FALSE;

  BOOL wResult = IO::WriteBuffer(wFile, &header, sizeof(header));

  CloseHandle(wFile);

  return TRUE;
}
